# $Id: Makefile,v 1.34 2006/06/27 01:21:28 tom_kelly33 Exp $

include Rules.mk
include Modules.mk

all: mklivecdcz

version:
	@echo "$(PKGNAME), $(MKLIVECDVER)-$(MKLIVECDREL)"

mklivecdcz:
	$(MKDIR) -p $(DISTDIR)
	$(CAT) $(SRCDIR)/$(PKGNAME).in | \
		$(SED) -e 's,@PKGNAME@,$(PKGNAME),g' | \
		$(SED) -e 's,@MKLIVECDVER@,$(ARCHIVEVER),g' | \
		$(SED) -e 's,@DEF_KEYBOARD@,$(DEF_KEYBOARD),g' | \
		$(SED) -e 's,@DEF_RESOLUTION@,$(DEF_RESOLUTION),g' | \
		$(SED) -e 's,@DEF_VGAMODE@,$(DEF_VGAMODE),g' | \
		$(SED) -e 's,@DEF_MODULES_PATH_26@,$(DEF_MODULES_PATH_26),g' | \
		$(SED) -e 's,@DEF_MODULES_OPT_PATH_26@,$(DEF_MODULES_OPT_PATH_26),g' | \
		$(SED) -e 's,@DEF_MODULES_DEP_PATH_26@,$(DEF_MODULES_DEP_PATH_26),g' | \
		$(SED) -e 's,@DEF_SCSI_MODULES_PATH_26@,$(DEF_SCSI_MODULES_PATH_26),g' | \
		$(SED) -e 's,@DEF_SCSI_MODULES_PATH_old26@,$(DEF_SCSI_MODULES_PATH_old26),g' | \
		$(SED) -e 's,@DEF_SCSI_MODULES_OPT_PATH_26@,$(DEF_SCSI_MODULES_OPT_PATH_26),g' | \
		$(SED) -e 's,@DEF_SCSI_MODULES_DEP_PATH_26@,$(DEF_SCSI_MODULES_DEP_PATH_26),g' | \
		$(SED) -e 's,@DEF_SCSI_MODULES_DEP_PATH_old26@,$(DEF_SCSI_MODULES_DEP_PATH_old26),g' | \
		$(SED) -e 's,@DEF_USB_MODULES_PATH_26@,$(DEF_USB_MODULES_PATH_26),g' | \
		$(SED) -e 's,@DEF_USB_MODULES_DRV_PATH_26@,$(DEF_USB_MODULES_DRV_PATH_26),g' \
			>$(DISTDIR)/$(PKGNAME)

install: install-doc
	$(MKDIR) -p $(DESTDIR)$(SHAREDIR)
	$(MKDIR) -p $(DESTDIR)$(SBINDIR)
	$(INSTALL) -m 755 $(DISTDIR)/$(PKGNAME) $(DESTDIR)$(SBINDIR)

install-doc:
	$(MKDIR) -p $(DESTDIR)$(DOCDIR)
	$(INSTALL) -m 644 $(DOCDIST) $(DESTDIR)$(DOCDIR)

spec:
	$(MKDIR) -p $(DISTDIR)
	$(CAT) $(PKGNAME).spec.in | \
		$(SED) -e 's,@MKLIVECDVER@,$(MKLIVECDVER),g' | \
		$(SED) -e 's,@MKLIVECDREL@,$(MKLIVECDREL),g' | \
		$(SED) -e 's,@SPECDATE@,$(SPECDATE),g' | \
		$(SED) -e 's,@ARCHIVEVER@,$(ARCHIVEVER),g' \
			>$(DISTDIR)/$(PKGNAME).spec
	$(CAT) CHANGELOG >>$(DISTDIR)/$(PKGNAME).spec

clean:
	$(RM) -rf $(MKLIVECDDIST)
	$(RM) -rf $(DISTDIR)
	$(RM) -rf $(SRCDIR)/*~

dist: spec
	$(MKDIR) -p $(MKLIVECDDIST)/$(SRCDIR)
	$(CP) $(DOCDIST) $(MKLIVECDDIST)
	$(CP) $(BUILDDIST) $(MKLIVECDDIST)
	$(CP) $(SRCDIST) $(MKLIVECDDIST)/$(SRCDIR)
	$(TAR) -c $(MKLIVECDDIST) | \
		$(BZIP2) >$(DISTDIR)/$(MKLIVECDDIST).tar.bz2
	$(MD5SUM) $(DISTDIR)/$(MKLIVECDDIST).tar.bz2 \
		>$(DISTDIR)/$(MKLIVECDDIST).tar.bz2.md5
	$(RM) -rf $(MKLIVECDDIST)
	
rpm: dist
	$(RPMBUILD) -ta $(DISTDIR)/$(MKLIVECDDIST).tar.bz2

rpm-install: rpm
	$(RPM) -Uvh --force /usr/src/rpm/RPMS/i586/$(PKGNAME)-$(MKLIVECDVER)-$(MKLIVECDREL)pclos2007.i586.rpm

gupload:
	gupload /usr/src/rpm/RPMS/i586/$(PKGNAME)-$(MKLIVECDVER)-$(MKLIVECDREL)pclos2007.i586.rpm "mklivecd script for creating PCLinuxOS LiveCD with czech boot theme - binary package"

upload:
	scp /usr/src/rpm/RPMS/i586/$(PKGNAME)-$(MKLIVECDVER)-$(MKLIVECDREL)pclos2007.i586.rpm dsmid@oko.clever.cz:www/pclinuxos/2007/RPMS.czech
	scp /usr/src/rpm/SRPMS/$(PKGNAME)-$(MKLIVECDVER)-$(MKLIVECDREL)pclos2007.src.rpm dsmid@oko.clever.cz:www/pclinuxos/2007/SRPMS.czech
	ssh dsmid@oko.clever.cz www/pclinuxos/2007/regenerate
